/* eslint-disable react/jsx-no-duplicate-props */
import React, {Component} from 'react'
import {Button, Form, Input, Radio, Select} from 'antd';
import {connect} from "react-redux";
import {removeEmptyField} from '../../compoent/emptyFild';


const {Option} = Select;

class PushAllMsg extends Component {


    onFinish = (values) => {
        const newValues = removeEmptyField(values)
         //测试
            if (newValues) {
                this.props.pushAllMsg(newValues).then(res => {
                    this.props.userList({ page: 1, size: 10 })
                })
            }

        this.props.handleCancel()
    };

    onFinishFailed = (errorInfo) => {

    };

    render() {
        return (
            <div>
                <Form
                    name="basic"
                    labelCol={{span: 6}}
                    wrapperCol={{span: 14}}
                    initialValues={{remember: true}}
                    onFinish={this.onFinish}
                    onFinishFailed={this.onFinishFailed}
                    autoComplete="off"
                >
                    <Form.Item
                        label="实名："
                        name="idStatus"
                        rules={[{required: true, message: '请选实名!'}]}
                    >
                        <Radio.Group options={[{label: '全部', value: -1}, {label: '实名', value: 1}]}/>
                    </Form.Item>


                    <Form.Item
                        label="性别："
                        name="sex"
                        rules={[{required: true, message: '请选择性别!'}]}
                    >
                        <Radio.Group options={[{label: '全部', value: -1}, {label: '女', value: 0}, {label: '男', value: 1}]}/>
                    </Form.Item>

                    <Form.Item
                        label="内容"
                        name="body"
                         rules={[{ required: true, message: '请输入内容!' }]}
                    >
                        <Input.TextArea/>
                    </Form.Item>

                    <Form.Item wrapperCol={{offset: 8, span: 16}}>
                        <Button type="primary" htmlType="submit">
                            确认
                        </Button>
                        <Button type="primary" htmlType="reset" style={{marginLeft: 30}}>
                            重置
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        )
    }
}

const mapState = state => ({
    ...state.users

});

const mapDispatch = dispatch => ({
    ...dispatch.users
})

export default connect(mapState, mapDispatch)(PushAllMsg);